const { Sequelize, DataTypes } = require("sequelize");
const sequelize = require(".");
const { status } = require("./enums");

const ReceptionBill = sequelize.define(
  "ReceptionBillDraft",
  {
    id: {
      type: Sequelize.UUID,
      defaultValue: Sequelize.UUIDV4,
      primaryKey: true,
    },
    status: {
      type: DataTypes.ENUM,
      values: status.map((it) => it.value),
      allowNull: false,
      defaultValue: null,
    },
    billNo: {
      type: DataTypes.STRING,
      defaultValue: null,
      unique: true,
    },
    content: {
      type: DataTypes.TEXT,
      defaultValue: null,
    }
  },
  {
    timestamps: true,
  }
);

// async function deleteAll() {
//   await ReceptionBill.destroy({
//     where: {},
//     truncate: true,
//   });
// }
// async function create(params) {
//   ReceptionBill.create({});
// }
(async () => {
  await ReceptionBill.sync({ alter: false }); // Creates the table if it doesn't exist
  // await deleteAll();
  // await create();
})();
exports.status = status;
module.exports = ReceptionBill;
